package com.itheima.jingjie.map;

import java.util.HashMap;
import java.util.Map;

public class Demo2 {
    public static void main(String[] args) {
        Map<String ,String> map=new HashMap<String, String>();
        System.out.println("添加三组数据如下: ");
        map.put("郭靖","黄蓉");
        map.put("杨过","小龙女");
        map.put("张无忌","周芷若");
        System.out.println(map);
        System.out.println("..................");
        map.put("张无忌","赵敏");
        System.out.println("修改张无忌-->赵敏:");
        System.out.println(map);
        System.out.println("..................");
        System.out.println("移除杨过的键值对如下:");
        String remove = map.remove("杨过");
        System.out.println(remove);
        System.out.println(map);
        System.out.println("..................");
        System.out.println("判断是否包含张无忌:");
        boolean containsKey = map.containsKey("张无忌");
        System.out.println(containsKey);
        System.out.println(map);
        System.out.println("..................");
        System.out.println("判断是否包含键:尹志平:");
        boolean yzp = map.containsKey("尹志平");
        System.out.println(yzp);
        System.out.println("..................");
        System.out.println("判断是否包含值灭绝师太:");
        boolean mjst = map.containsValue("灭绝师太");
        System.out.println(mjst);
        System.out.println("..................");
        System.out.println("map集合的键值对个数:"+map.size());
        System.out.println("..................");
        System.out.println("判断集合是否为空:   "+map.isEmpty());
        System.out.println("..................");
        System.out.println(map);
        System.out.println("清空集合:   ");
        map.clear();
        System.out.println("..................");
        System.out.println("判断集合是否为空:   ");
        System.out.println(map.isEmpty());
        System.out.println(map);


    }
}
